const path = require('path');
const fs=require('fs');
module.exports=class extends baseLogic{
    constructor(){
        super();

    }

    async getInfo(label){
        return new Promise( (resolve,reject)=> {
            let filePath=path.resolve()+"/common/module/cms/config/"+label+".json";
             fs.readFile(filePath,{encoding:'utf8'},function (err,ret) {
                if(err){
                    reject(err);
                }else{
                    let siteInfo=JSON.parse(ret);
                    resolve(siteInfo);
                }
            });
        });
    }

    async setInfo(label,model){
        if(model){
            return new Promise( (resolve,reject)=> {
                let _path=path.resolve()+"/common/module/cms/config/"+label+".json";
                fs.writeFile(_path,JSON.stringify(model),function (err) {
                    if(err){
                        reject(err);
                    }else{
                        resolve(true);
                    }
                });
            });
        }
        return false;
    }

};
